// 封装选择器函数
function $(selector){
    var c=selector.substring(0,1);//获取第一个字符
    if(c=="#"){
        return document.getElementById(selector.substring(1,selector.length));//返回相应的元素
    }else if(c == '.'){
        return document.getElementsByClassName(selector.substring(1,selector.length))
    }else{
        return document.getElementsByTagName(selector);
    }
}

function changeBcg(i){
    let articalList = $('.articalList')
    for(var a = 0;a < articalList.length;a++){
        if(i-1 === a){
            articalList[a].style.backgroundColor = '#F3CCCF'
            articalList[a].style.color = 'white'
        }else{
            articalList[a].style.backgroundColor = 'white'
            articalList[a].style.color = '#d6555f'
        }
    }
    
}
changeBcg(1)

// 点左边的右边也要跟着变一下
let rightContent = $('.rightContent')
for(let i = 0;i < $('.articalList').length;i++){
    $('.articalList')[i].onclick = function(){
        changeBcg(i+1)
        for(var a = 0;a < rightContent.length;a++){
            if(a === i){
                rightContent[a].style.display = 'block'
            }else{
                rightContent[a].style.display = 'none'

            }
        }
    }
}